import { Routes, Route, Navigate } from 'react-router-dom';
import CustomRouter from './components/CustomRouter';
import Login from '@/pages/Login';
import './App.scss';
import Layout from '@/pages/Layout';
import { customHistory } from './utils/history';
import Home from './pages/Home';
import Question from './pages/Question';
import Video from './pages/Video';
import Profile from './pages/Profile';
import ProfileEdit from './pages/Profile/Edit';
import AuthRoute from './components/AuthRoute';

function App() {
  return (
    <CustomRouter history={customHistory}>
      <div className="app">
        <Routes>
          <Route path="/" element={<Navigate to="/Home" />} />
          <Route path="/Login" element={<Login />} />
          <Route path="/home" element={<Layout />}>
            <Route index element={<Home />} />
            <Route path="qs" element={<Question />} />
            <Route path="video" element={<Video />} />
            {/* 个人信息 */}
            <Route
              path="profile"
              element={
                <AuthRoute>
                  <Profile />
                </AuthRoute>
              }
            />
          </Route>
          <Route element={<AuthRoute />}>
            <Route path="/profile/Edit" element={<ProfileEdit />} />
          </Route>
        </Routes>
      </div>
    </CustomRouter>
  );
}

export default App;
